{extend name="public/header" /}

{block name="title"}{:env('SITE_NAME')}{/block}
{block name="css"}
<link rel="stylesheet" href="/static/admin/css/login.css">
{/block}

{block name="body"}
<body class="login-bg">

  <div class="login">
    <div class="message">登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form">
      <input name="username" placeholder="admin" type="text" lay-verify="required" class="layui-input">
      <hr class="hr15">
      <input name="password" lay-verify="required" placeholder="123456" type="password" class="layui-input">
      <hr class="hr15">
      <input class="loginin" value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
      <hr class="hr20">
    </form>
  </div>

  <!-- 底部结束 -->
</body>
<script>
  $(function () {
      layui.use('form', function () {
          var form = layui.form;

          //监听提交
          form.on('submit(login)', function (obj) {
              $.ajax({
                  type: "post",
                  url: obj.form.action,
                  data: obj.field,
                  dataType: "json",
                  success: function (res) {
                      if (res.code != 0) {
                          layer.msg(res.msg, {
                              icon: 2,
                              time: 2000//2秒关闭（如果不配置，默认是3秒）
                          });
                      } else {
                          window.location.href = "{:url('/admin/index/index')}";
                      }
                  }
              });
              return false;
          });
      });
  })
</script>
{/block}